<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>BOOST_OUTCOME_CO_TRY_FAILURE_LIKELY(var, expr) - Boost.Outcome documentation</title>
<link rel="stylesheet" href="../../css/boost.css" type="text/css">
<meta name="generator" content="Hugo 0.52 with Boostdoc theme">
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>

<link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
<body><div class="spirit-nav">
<a accesskey="p" href="../../reference/macros/co_tryx_failure_likely.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../reference/macros.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/macros/disable_execinfo.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  <div class="titlepage"><div><div><h1 style="clear: both"><code>BOOST_OUTCOME_CO_TRY_FAILURE_LIKELY(var, expr)</code></h1></div></div></div>
  <p>Evaluate within a coroutine an expression which results in a type matching the following customisation points, assigning <code>T</code> to a decl called <code>var</code> if successful, immediately returning <a href="../../reference/functions/try_operation_return_as.html" class="api-reference"><code>try_operation_return_as(X)</code></a>
 from the calling function if unsuccessful:</p>

<ul>
<li><code>BOOST_OUTCOME_V2_NAMESPACE::</code><a href="../../reference/functions/try_operation_has_value.html" class="api-reference"><code>try_operation_has_value(X)</code></a>
</li>
<li><code>BOOST_OUTCOME_V2_NAMESPACE::</code><a href="../../reference/functions/try_operation_return_as.html" class="api-reference"><code>try_operation_return_as(X)</code></a>
</li>
<li><code>BOOST_OUTCOME_V2_NAMESPACE::</code><a href="../../reference/functions/try_operation_extract_value.html" class="api-reference"><code>try_operation_extract_value(X)</code></a>
</li>
</ul>

<p>Default overloads for these customisation points are provided. See <a href="../../recipes/foreign-try.html">the recipe for supporting foreign input to <code>BOOST_OUTCOME_TRY</code></a>.</p>

<p>Hints are given to the compiler that the expression will be unsuccessful. If you expect success, you should use <a href="../../reference/macros/co_try.html" class="api-reference"><code>BOOST_OUTCOME_CO_TRY(var, expr)</code></a>
 instead.</p>

<p>An internal temporary to hold the value of the expression is created, which generally invokes a copy/move. <a href="../../tutorial/essential/result/try_ref.html">If you wish to never copy/move, you can tell this macro to create the internal temporary as a reference instead.</a></p>

<p><em>Overridable</em>: Not overridable.</p>

<p><em>Definition</em>: See <a href="../../reference/macros/co_tryv.html" class="api-reference"><code>BOOST_OUTCOME_CO_TRYV(expr)</code></a>
 for most of the mechanics.</p>

<p>If successful, <code>var</code> is initialised or assigned to the expression result&rsquo;s <code>.assume_value()</code> if available, else to its <code>.value()</code>. This binds a reference possibly to the <code>T</code> stored inside the bound result of the expression, but possibly also to a temporary emitted from the value observer function.</p>

<p><em>Header</em>: <code>&lt;boost/outcome/try.hpp&gt;</code></p>

<p><em>Legacy</em>: Before Outcome v2.2, <code>var</code> was always declared as an automatic rvalue ref. You can use the backwards compatibility macro <code>OUTCOME21_CO_TRY()</code> if wish to retain the old behaviour.</p>


        </div><p><small>Last revised: February 12, 2021 at 20:25:43 UTC</small></p>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../reference/macros/co_tryx_failure_likely.html"><img src="../../images/prev.png" alt="Prev"></a>
    <a accesskey="u" href="../../reference/macros.html"><img src="../../images/up.png" alt="Up"></a>
    <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/macros/disable_execinfo.html"><img src="../../images/next.png" alt="Next"></a></div></body>
</html>
